<extend name="Layout:layout_dialog" />
<block name="body_main">
    <form action="{:U('setting_picker_save')}" method="post" class="xsui-form">
        <label>设置分店：</label>
        <input type="checkbox" id="chkall" />全选
        <div id="chkgroup" style="margin:10px 0">
            <foreach name="list" item="vo">
                <input type="checkbox" name="id[]" value="{$vo.id}" />{$vo.text}&nbsp;&nbsp;
            </foreach>
        </div>
        <button type="submit" class="ui-state-default"><i class="fa fa-save"></i>保存</button>
        <button type="reset" class="ui-state-default">重置</button>
        <input type="hidden" name="uid" value="{$uid}"/>
        <input type="hidden" id="ids" value="{$ids}"/>
        <input type="hidden" name="field" value="branch_ids" />
    </form>
</block>
<block name="body_after">    
    <script type="text/javascript">
        $(function () {
            $('#chkall').click(function(){
                $('#chkgroup input').prop('checked',$(this).prop('checked'));
            })
            chk_pick();
        })
        // 2016-5-31
        function chk_pick() {
            var ids = $('#ids').val();
            if (ids) {
                var aids = ids.split(',');
                var sel = '';
                for (var i in aids) {
                    if (sel) {
                        sel += ',';
                    }
                    sel += '[value="' + aids[i] + '"]';
                }
                $('#chkgroup').find(sel).prop('checked', true);
            }
        }
    </script>
</block>